package com.grsu.phonestation.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.transaction.annotation.Transactional;

import com.grsu.phonestation.dao.ServiceDAO;
import com.grsu.phonestation.domain.Service;
import com.grsu.phonestation.service.ServiceService;

@org.springframework.stereotype.Service
@Transactional
public class ServiceServiceImpl<S extends Service> implements ServiceService<S>{

	@Autowired
	@Qualifier("serviceDAOImpl")
	private ServiceDAO<S> serviceDAO;
	
	public ServiceDAO<S> getDao(){
		return serviceDAO;
	}
	
	@Override
	public void addService(S service) {
		getDao().save(service);

	}

	@Override
	public void editService(S service) {
		getDao().update(service);

	}

	@Override
	public void removeService(int serviceId) {
		getDao().remove(serviceId);

	}

	@Override
	public S getServiceById(int serviceId) {
		S service = getDao().findById(serviceId);
		return service;

	}

	@Override
	public List<S> listServices() {
		List<S> services = getDao().findAll();
		return services;
	}
	
}
